public class Factorial

{
  public static void main( String [] args )
  {
int n;
n = factorial(3);
    System.out.println( "Factorial is "+n );
  }
 
  public static int factorial( int n )
  {
    if ( n <= 0 )  
     return 1;
    else    // general case
     return ( n * factorial ( n - 1 ) );
  }
}
